﻿using B.MESUI.Login.BasicData_UI.BasicData;
using B.MESUI.Login.Properties;
using DevExpress.XtraEditors;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace B.MESUI.Login.BasicData_UI.Supplier
{
    public partial class AddSupplierForm : DevExpress.XtraEditors.XtraForm
    {
        public delegate void Supplier_LoadEvent();
        public event Supplier_LoadEvent Supplier_Load;
        public AddSupplierForm()
        {
            InitializeComponent();
            //页面中间
            this.CenterToScreen();
        }

        private void SuppliersimpleButton1_Click(object sender, EventArgs e)
        {
            string url = Settings.Default.BaseUrl_SLY + MethodConst.AddSupplier;
            string jsonData = JsonConvert.SerializeObject(new AddSupplierDTO
            {
                supplieR_CODE = textEdit1.Text,
                supplieR_ABBREVIATION = textEdit2.Text,
                supplieR_ADDRESS = textEdit3.Text,
                supplieR_NODE = textEdit4.Text,
                supplieR_NAME = textEdit5.Text,
                supplieR_PHONE = textEdit7.Text,
                crediT_CODE = textEdit6.Text,
                
            });
            var repose = BaseMethod.MethodsURL("post",url, jsonData);
            if (repose != null)
            {
                MessageBox.Show("添加成功");
                Supplier_Load.Invoke();
                this.Close();
            }
            else
            {
                MessageBox.Show("添加失败");
            }
        }

        private void SupplierResetsimpleButton2_Click(object sender, EventArgs e)
        {
            textEdit1.Text = "";
            textEdit5.Text = "";
            textEdit2.Text = "";
            textEdit6.Text = "";
            textEdit3.Text = "";
            textEdit7.Text = "";
            textEdit4.Text = "";
        }
    }
}